#include"string.h"

void test01()
{
	tianci::string s1;
	tianci::string s2("hello tianci");
	cout << s1.size() << endl;
	cout << s2.size() << endl;
	cout << s1.capacity() << endl;
	cout << s2.capacity() << endl;
	cout << s1.empty() << endl;
	cout << s2.empty() << endl;
	s1.resize(2, 'c');
	s2.resize(s2.size() + 5, '+');
	cout << s1<< endl;
	cout << s2<< endl;

	tianci::string::iterator it = s2.begin();
	while (it != s2.end())
	{
		(*it)++;
		++it;
	}
	for (auto& ch : s2)
	{
		cout << ch << ' ';
	}
}

void test02()
{
	tianci::string s1;
	tianci::string s2("hello tianci");
	s1.push_back('c');
	s2 += '!';
	cout << s1 << endl;
	cout << s2 << endl;
	s1.append("ww");
	s2 += "113";
	cout << s1 << endl;
	cout << s2 << endl;
	s1.clear();
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
}

void test03()
{
	tianci::string s1("hello tianci");
	size_t pos1 = s1.find('o');
	cout << pos1 << endl;
	size_t pos2 = s1.find("an");
	cout << pos2 << endl;

	s1.insert(0, 'h');
	cout << s1 << endl;
	s1.insert(6, "cc");
	cout << s1 << endl;
	s1.erase(6, 2);
	cout << s1 << endl;
}

void test04()
{
	tianci::string s1("abcde");
	tianci::string s2("hello tianci");
	cout << (s1 == s2) << endl;
	cout << (s1 <= s2) << endl;
	cout << (s1 >= s2) << endl;
	cout << (s1 < s2) << endl;
	cout << (s1 > s2) << endl;
}

void test05()
{
	tianci::string s1("hello tianci");
	tianci::string s2(s1);
	cout << s1 << endl;
	cout << s2 << endl;
	tianci::string s3 = "abcabc";
	s2 = s3;
	cout << s1 << endl;
	cout << s2 << endl;
	cout << s3 << endl;

	s1.swap(s2);
	cout << s1 << endl;
	cout << s2 << endl;
	cout << s3 << endl;
}


int main()
{
	test05();

	return 0;
}